package com.zyh.thread.demo4;

/**
 * @Author zyh
 * @Date 2024/8/8 14:54
 * @Description 生产者任务
 */

public class MyTask01 implements Runnable {
    private Stack stack;

    public MyTask01() {
    }

    public MyTask01(Stack stack) {
        this.stack = stack;
    }

    @Override
    public void run() {
        int i = 0;
        while (true) {
            //交替生产
            if (i % 2 == 0) {
                stack.create("馒头", "黄色");
            } else {
                stack.create("包子", "白色");
            }
            i++;
        }
    }
}
